﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.SqlClient;
using SIPO.Library.DomainObject.Transaction;
using SIPO.Library.DomainObject.Administration.Catalog;

namespace SIPO.Library.DataAccess.Report
{
    class rptRegistrasi
    {
        private string connectionString;

        public rptRegistrasi(string connectionString)
        {
            this.connectionString = connectionString;
        }

//        public List<recRegistration> getreportregristation (int sectorID, int subsektorID, int subsubsectorID)
//        {
//            List<recSector> tt = new List<recSector>();

//            using (SqlConnection conn = new SqlConnection(connectionString))
//            {
//                using (SqlCommand cmd = conn.CreateCommand())
//                {
//                    cmd.CommandText = @"
//                                    select master.recSector.SectorName,
//                                    master.recSubSector.SubSectorName,
//                                    master.recSubSubSector.SubSubSectorName
//                                    from master.recSector
//                                    inner join master.recSubSector on master.recSector.SectorID = master.recSubSector.SectorID 
//                                    inner join master.recSubSubSector on master.recSubSubSector.SubSectorID = master.recSubSector.SectorID 
//                                    where master.recSector.SectorID = @sectorID 
//                                    and master.recSubSector.SubSectorID = @subsectorID
//                                    and master.recSubSubSector.SubSubSectorID = @subsubsectorID";
//                    cmd.CommandType = CommandType.Text;

//                    cmd.Parameters.Add("@sectorID", SqlDbType.Int ).Value= sectorID;
//                    cmd.Parameters.Add("@subsectorID", SqlDbType.Int).Value = subsektorID;
//                    cmd.Parameters.Add("@subsubsectorID", SqlDbType.Int).Value = subsubsectorID;
//                    try
//                    {
//                        conn.Open();
//                        using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
//                        {
//                            while (dr.Read())
//                            {
//                                recSubSubSector t = new recSubSubSector(true);
//                                recSubSector s = new recSubSector(true);
//                                recSector a = new recSector();
//                                a.SectorName = dr[recSector.Fields.SectorName] == DBNull.Value ? null : dr[recSector.Fields.SectorName].ToString();
//                                s.SubSectorName = dr[recSubSector.Fields.SubSectorName] == DBNull.Value ? null : dr[recSubSector.Fields.SubSectorName].ToString();
//                                t.SubSubSectorName = dr[recSubSubSector.Fields.SubSubSectorName] == DBNull.Value ? null : dr[recSubSubSector.Fields.SubSubSectorName].ToString();
//                                //t.TransTypeID = dr[recBilling.Fields.TransTypeID] == DBNull.Value ? (short)0 : Convert.ToInt16(dr[recBilling.Fields.TransTypeID]);
//                                //t.recTransactionType.TransTypeName = dr[recTransactionType.Fields.TransTypeName] == DBNull.Value ? string.Empty : dr[recTransactionType.Fields.TransTypeName].ToString();
//                                //t.Value = dr[recBilling.Fields.Value] == DBNull.Value ? (decimal)0 : Convert.ToDecimal(dr[recBilling.Fields.Value]);
//                                //t.Balance = dr[recBilling.Fields.Balance] == DBNull.Value ? (decimal)0 : Convert.ToDecimal(dr[recBilling.Fields.Balance]);
//                                //t.BillingDate = dr[recBilling.Fields.BillingDate] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(dr[recBilling.Fields.BillingDate]);
//                                //t.DueDate = dr[recBilling.Fields.DueDate] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(dr[recBilling.Fields.DueDate]);

//                                tt.Add(t);
//                                t.Dispose();
//                            }
//                        }
//                    }
//                    catch (Exception ex)
//                    {
//                        throw (ex);
//                    }
//                    finally
//                    {
//                        if (conn.State == ConnectionState.Open)conn.Close();
//                    }
//                }
//            }
//        }
    }
}
